Event   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 80
dl 0
loc 91
c 0
b 0
f 0
rs 10

9 Functions

Rating   Name   Duplication   Size   Complexity  
A getTime 0 3 1
A getId 0 3 1
A getDate 0 3 1
A getType 0 3 1
A update 0 13 1
A getTask 0 3 1
A getUser 0 3 1
A getSummary 0 3 1
A getProject 0 3 1
1
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2
import { Task } from '../Task/Task.entity';
3
import { Project } from '../Project/Project.entity';
4
import { User } from '../HumanResource/User/User.entity';
5
6
export enum EventType {
7
  MISSION = 'mission',
8
  SUPPORT = 'support',
9
  DOJO = 'dojo',
10
  FORMATION_CONFERENCE = 'formationConference',
11
  OTHER = 'other'
12
}
13
14
@Entity()
15
export class Event {
16
  public static readonly MAXIMUM_TIMESPENT_PER_DAY: number = 720;
17
18
  @PrimaryGeneratedColumn('uuid')
19
  private id: string;
20
21
  @Column('enum', { enum: EventType, nullable: false })
22
  private type: EventType;
23
24
  @Column({ type: 'integer', nullable: false, comment: 'Stored in minutes' })
25
  private time: number;
26
27
  @Column({ type: 'date', nullable: false })
28
  private date: string;
29
30
  @Column({ type: 'varchar', nullable: true })
31
  private summary: string;
32
33
  @ManyToOne(type => Project, { nullable: true, onDelete: 'SET NULL' })
34
  private project: Project;
35
36
  @ManyToOne(type => Task, { nullable: true, onDelete: 'SET NULL' })
37
  private task: Task;
38
39
  @ManyToOne(type => User, { nullable: false, onDelete: 'CASCADE' })
40
  private user: User;
41
42
  constructor(
43
    type: EventType,
44
    user: User,
45
    time: number,
46
    date: string,
47
    project?: Project,
48
    task?: Task,
49
    summary?: string
50
  ) {
51
    this.type = type;
52
    this.user = user;
53
    this.time = time;
54
    this.date = date;
55
    this.project = project;
56
    this.task = task;
57
    this.summary = summary;
58
  }
59
60
  public getId(): string {
61
    return this.id;
62
  }
63
64
  public getType(): string {
65
    return this.type;
66
  }
67
68
  public getTime(): number {
69
    return this.time;
70
  }
71
72
  public getDate(): string {
73
    return this.date;
74
  }
75
76
  public getSummary(): string | null {
77
    return this.summary;
78
  }
79
80
  public getProject(): Project | null {
81
    return this.project;
82
  }
83
84
  public getTask(): Task | null {
85
    return this.task;
86
  }
87
88
  public getUser(): User {
89
    return this.user;
90
  }
91
92
  public update(
93
    type: EventType,
94
    time: number,
95
    project?: Project,
96
    task?: Task,
97
    summary?: string
98
  ): void {
99
    this.type = type;
100
    this.time = time;
101
    this.project = project;
102
    this.task = task;
103
    this.summary = summary;
104
  }
105
}
106